using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Service.Order.IOrderService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-01-12
namespace JTZY.Admin.WebApi.Controllers.Order
{
    /// <summary>
    /// 发货单表
    /// </summary>
    [Verify]
    [Route("order/Corecmsbilldelivery")]
    public class CorecmsbilldeliveryController : BaseController
    {
        /// <summary>
        /// 发货单表接口
        /// </summary>
        private readonly ICorecmsbilldeliveryService _CorecmsbilldeliveryService;

        public CorecmsbilldeliveryController(ICorecmsbilldeliveryService CorecmsbilldeliveryService)
        {
            _CorecmsbilldeliveryService = CorecmsbilldeliveryService;
        }

        /// <summary>
        /// 查询发货单表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsbilldelivery:list")]
        public IActionResult QueryCorecmsbilldelivery([FromQuery] CorecmsbilldeliveryQueryDto parm)
        {
            var response = _CorecmsbilldeliveryService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询发货单表详情
        /// </summary>
        /// <param name="DeliveryId"></param>
        /// <returns></returns>
        [HttpGet("{DeliveryId}")]
        [ActionPermissionFilter(Permission = "corecmsbilldelivery:query")]
        public IActionResult GetCorecmsbilldelivery(string DeliveryId)
        {
            var response = _CorecmsbilldeliveryService.GetInfo(DeliveryId);
            
            var info = response.Adapt<CorecmsbilldeliveryDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加发货单表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsbilldelivery:add")]
        [Log(Title = "发货单表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsbilldelivery([FromBody] CorecmsbilldeliveryDto parm)
        {
            var modal = parm.Adapt<Corecmsbilldelivery>().ToCreate(HttpContext);

            var response = _CorecmsbilldeliveryService.AddCorecmsbilldelivery(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新发货单表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsbilldelivery:edit")]
        [Log(Title = "发货单表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsbilldelivery([FromBody] CorecmsbilldeliveryDto parm)
        {
            var modal = parm.Adapt<Corecmsbilldelivery>().ToUpdate(HttpContext);
            var response = _CorecmsbilldeliveryService.UpdateCorecmsbilldelivery(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除发货单表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsbilldelivery:delete")]
        [Log(Title = "发货单表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsbilldelivery([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<string>(ids);

            return ToResponse(_CorecmsbilldeliveryService.Delete(idArr));
        }

    }
}